package com.kt.delivery.controller;


import com.kt.delivery.domain.R;
import com.kt.delivery.domain.dto.OtherOrderDto;
import com.kt.delivery.domain.dto.TakingOrderDto;
import com.kt.delivery.domain.vo.TakingOrderVo;
import com.kt.delivery.service.TakingOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/takingOrder")
public class TakingOrderController {

    private final TakingOrderService takingOrderService;

    /**
     * 接单员页面  代取件下代接订单列表
     * @param takingOrderDto 参数
     * @return 结果
     */
    @GetMapping("/getTakeOrder")
    public R<List<TakingOrderVo>> getTakeOrder(TakingOrderDto takingOrderDto){
        return R.ok(takingOrderService.getTakeOrder(takingOrderDto));
    }

    /**
     * 接单员页面  代取件下的（已接订单 配送订单 历史订单 的列表）
     * @param takingOrderDto 参数
     * @return 结果
     */
    @GetMapping("/getTakeIdOrder")
    public R<List<TakingOrderVo>> getTakeIdOrder(TakingOrderDto takingOrderDto, HttpServletRequest httpServletRequest){

        return R.ok(takingOrderService.getTakeIdOrder(takingOrderDto,httpServletRequest));
    }

    /**
     * 接单员页面  代寄下代接订单列表
     * @param otherOrderDto 参数
     * @return 结果
     */
    @GetMapping("/getOthersOrder")
    public R<List<TakingOrderVo>> getOthersOrder(OtherOrderDto otherOrderDto) {
        return R.ok(takingOrderService.getOthersOrder(otherOrderDto));
    }

    /**
     * 接单员页面  代寄下（已接订单 配送订单 历史订单 的列表）
     * @param otherOrderDto 参数
     * @param
     * @return 结果
     */
    @GetMapping("/getOthersStatusOrder")
    public R<List<TakingOrderVo>> getOthersStatusOrder(OtherOrderDto otherOrderDto){
        return R.ok(takingOrderService.getOthersStatusOrder(otherOrderDto));
    }


    /**
     * 接单
     * @param orderId
     * @return
     */
    @PutMapping("/updateTakeOrders")
    public R<Integer> updateTakeOrders(String orderId){
        return R.ok(takingOrderService.TakeOrders(orderId));
    }


    /**
     * 开始派送
     * @param orderId 订单id
     * @return 结果
     */
    @PutMapping("/Dispatch")
    public R<Integer> Dispatch(String orderId){
        return R.ok(takingOrderService.Dispatch(orderId));
    }
}
